#include <stdio.h>
#include <math.h>

/**
 * 空格实心菱形
 * @param length
 */
void print1(int length) {
    for (int i = 0; i < length; ++i) {
        for (int j = abs(length / 2 - i); j > 0; j--) {
            printf(" ");
        }
        for (int j = length / 2 - abs(length / 2 - i); j >= 0; j--) {
            printf("* ");
        }
        printf("\n");
    }
}

/**
 * 密集实心菱形
 * @param length
 */
void print2(int length) {
    for (int i = 0; i < length; ++i) {
        for (int j = abs(length / 2 - i); j > 0; j--) {
            printf(" ");
        }
        for (int j = length - abs(2 * i - (length >> 1 << 1)); j > 0; j--) {
            printf("*");
        }
        printf("\n");
    }
}

/**
 * 空格空心菱形
 * @return
 */
void print3(int length) {
    for (int i = 0; i < length; ++i) {
        for (int j = abs(i - length / 2); j > 0; --j) {
            printf(" ");
        }
        printf("*");
        for (int j = length - 2 - abs(2 * i - (length >> 1 << 1)); j > 0; --j) {
            printf(" ");
        }
        if (i > 0 && i < length - 1) {
            printf("*");
        }
        printf("\n");
    }
}

double getLimit(int i, int length) {
    return pow(length / 2, 2) - pow(i - length / 2, 2);
}

/**
 * 实心圆
 * @param length
 */
void print4(int length) {
    for (int i = 0; i < length; ++i) {
        double limit = getLimit(i, length);
        for (double j = length / 2 - sqrt(limit); j > 0; --j) {
            printf("  ");
        }
        for (double j = sqrt(limit); j >= 0; j -= 0.5) {
            printf("* ");
        }
        printf("\n");
    }
}

/**
 * 空心圆
 * @param length
 */
void print5(int length) {
    for (int i = 0; i < length; ++i) {
        double limit = getLimit(i, length);
        for (double j = length / 2 - sqrt(limit); j > 0; --j) {
            printf("  ");
        }
        printf("*");
        for (double j = sqrt(limit); j >= 0; j -= 0.5) {
            printf("  ");
        }
        printf("*\n");
    }
}